#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1,    FlipperGyro,    sensorGyro)
#pragma config(Sensor, in2,    ArmPot,         sensorPotentiometer)
#pragma config(Sensor, in3,    FlipperPot,     sensorPotentiometer)
#pragma config(Sensor, in4,    Auton_Pot,      sensorPotentiometer)
#pragma config(Sensor, in5,    Gyro,           sensorNone)
#pragma config(Sensor, dgtl1,  JawChanger,     sensorTouch)
#pragma config(Sensor, I2C_1,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Sensor, I2C_2,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Sensor, I2C_4,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Sensor, I2C_5,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Sensor, I2C_6,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Motor,  port1,           RightBaseBack, tmotorVex393HighSpeed, PIDControl, reversed, encoder, encoderPort, I2C_2, 1000)
#pragma config(Motor,  port2,           LeftArm,       tmotorVex393HighSpeed, PIDControl, reversed, encoder, encoderPort, I2C_4, 1000)
#pragma config(Motor,  port3,           RightArm,      tmotorVex393, openLoop, reversed)
#pragma config(Motor,  port4,           LeftBaseFront, tmotorVex393, openLoop)
#pragma config(Motor,  port5,           TheJaw,        tmotorVex269, openLoop, reversed)
#pragma config(Motor,  port6,           FlipperMotorLeft, tmotorVex269, openLoop, reversed, encoder, encoderPort, I2C_5, 1000)
#pragma config(Motor,  port7,           FlipperMotorRight, tmotorVex269, openLoop, encoder, encoderPort, I2C_6, 1000)
#pragma config(Motor,  port8,           LeftBaseBack,  tmotorVex393, openLoop)
#pragma config(Motor,  port9,           Convayer,      tmotorVex393, openLoop)
#pragma config(Motor,  port10,          RightBaseFront, tmotorVex393HighSpeed, PIDControl, reversed, encoder, encoderPort, I2C_1, 1000)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

// global variable to check the status of the flipper hold button press
bool FlipperHoldButton = false;
// global variable to hold the gyro value
int FlipperGyroValue = 1;

task FlipperGyroHold()
{
  // get the current value of the gyro so we know where to hold the flipper
  FlipperGyroValue = SensorValue(FlipperGyro);
  // start holding the flipper in place - enter an infinite loop (until stop task is called, the code in here will continue to operate)
  while(true)
  {
    // do whatever you need to do to keep the flipper near the value
    if(SensorValue(FlipperGyro) < FlipperGyroValue)
    {
      motor(FlipperMotorRight) = 127;
      motor(FlipperMotorLeft) = 127;
    }
    if(SensorValue(FlipperGyro) > FlipperGyroValue)
    {
      motor(FlipperMotorRight) = -70;
      motor(FlipperMotorLeft) = -70;
    }
  }
}

// add this as one of the functions that gets called in the infinite loop in the user control section of the code
void FlipperHold()
{
  if(vexRT(Btn8UXmtr2) == true)
  {
    if (FlipperHoldButton == true)
    {
      // turn off the hold
      StopTask(FlipperGyroHold);
      FlipperHoldButton = false;
    }
    else
    {
      // turn on the hold
      StartTask(FlipperGyroHold);
      FlipperHoldButton = true;
    }
  }
  else
  {
    // if the button is not pressed, do nothing (until the button is pressed again)
  }
}

task main()
{



}
